Clean up syntax for supported Python versions.#1963
Clean up syntax for supported Python versions.#1963pcmoritz merged 5 commits intoray-project:masterfrom
Conversation
Ran code through [pyupgrade](https://github.com/asottile/pyupgrade). This is supported in every Python version 2.7+.
No need to specify 0,1.. if paramters are passed in order.
|
Test PASSed. |
| out_names = set() | ||
| else: | ||
| out_names = set(names[oparg] | ||
| for op, oparg in _walk_global_ops(co)) |
There was a problem hiding this comment.
Let's not make any changes to this file as it is directly copied from the cloudpickle repository.
There was a problem hiding this comment.
Good point. Put in a PR w/cloudpickle to change that though.
python/ray/dataframe/dataframe.py
Outdated
| result = self._repr_helper_() | ||
| final_result = repr(result).rsplit("\n\n", maxsplit=1)[0] + \ | ||
| "\n\n[{0} rows x {1} columns]".format(len(self.index), | ||
| "\n\n[{} rows x {} columns]".format(len(self.index), |
There was a problem hiding this comment.
If we do this change (and others) we'll need to fix the indentation of the next line
There was a problem hiding this comment.
I'm fine leaving this as is then, though I'd prefer that there be a git hook to require all code to be run through auto-formatters. It'd unify things like the use of certain syntax, indent, and quote styles.
|
@devin-petersohn can you take a look at the changes to the dataframes files and see if these make sense to you? If you prefer we can make these changes only for non-dataframes files. |
|
@robertnishihara @alok These changes are fine for the dataframes files. Thanks! |
This reverts commit efa5ec8.
Drop use of set literal until cloudpickle uses it.
|
I think those are both of the necessary changes. |
|
Test PASSed. |
|
Looks good, thanks! There are still a couple linting errors at https://travis-ci.org/ray-project/ray/jobs/372891975. Could you fix those? |
We need to set up a git pre-push hook to automatically run this stuff.
|
I think that's all the lint errors taken care of. |
|
Thanks @alok, yapf seems to be complaining (though unfortunately it doesn't list the diff). |
|
@robertnishihara I ran yapf locally with the same flags and it gave no changes. Travis says the build ran 19 hours ago, so maybe it hasn't picked up the changes yet? |
This should probably be merged after ray-project#1963.
|
There are still linting errors, can you have another look? |
|
Maybe it's a version issue with yapf? |
|
The cloudpickle changes were just merged in, so we can pick them up next time we update those files. |
|
Closing and reopening a PR apparently forces Travis to rebuild, and the lint test is green now. |
|
Jenkins test this please |
|
Test PASSed. |
* magic-methods: fmt Fix IndentationError Write magic methods for SampleBatch/PartialRollout Clean up syntax for supported Python versions. (ray-project#1963) [DataFrame] Implements mode, to_datetime, and get_dummies (ray-project#1956) [DataFrame] Fix dtypes (ray-project#1930) keep_dims -> keepdims (ray-project#1980) add pthread linking (ray-project#1986) [DataFrame] Add layer of abstraction to allow OID instantiation (ray-project#1984) [DataFrame] Fix blocking issue on _IndexMetadata passing (ray-project#1965)
* master: (21 commits) Expand local_dir in Trial init (ray-project#2013) Fixing ascii error for Python2 (ray-project#2009) [DataFrame] Implements df.update (ray-project#1997) [DataFrame] Implements df.as_matrix (ray-project#2001) [DataFrame] Implement quantile (ray-project#1992) [DataFrame] Impement sort_values and sort_index (ray-project#1977) [DataFrame] Implement rank (ray-project#1991) [DataFrame] Implemented prod, product, added test suite (ray-project#1994) [DataFrame] Implemented __setitem__, select_dtypes, and astype (ray-project#1941) [DataFrame] Implement diff (ray-project#1996) [DataFrame] Implemented nunique, skew (ray-project#1995) [DataFrame] Implements filter and dropna (ray-project#1959) [DataFrame] Implements df.pipe (ray-project#1999) [DataFrame] Apply() for Lists and Dicts (ray-project#1973) Clean up syntax for supported Python versions. (ray-project#1963) [DataFrame] Implements mode, to_datetime, and get_dummies (ray-project#1956) [DataFrame] Fix dtypes (ray-project#1930) keep_dims -> keepdims (ray-project#1980) add pthread linking (ray-project#1986) [DataFrame] Add layer of abstraction to allow OID instantiation (ray-project#1984) ...
* master: (25 commits) [DataFrame] Add direct pandas imports for MVP (ray-project#1960) Make ActorHandles pickleable, also make proper ActorHandle and ActorC… (ray-project#2007) Expand local_dir in Trial init (ray-project#2013) Fixing ascii error for Python2 (ray-project#2009) [DataFrame] Implements df.update (ray-project#1997) [DataFrame] Implements df.as_matrix (ray-project#2001) [DataFrame] Implement quantile (ray-project#1992) [DataFrame] Impement sort_values and sort_index (ray-project#1977) [DataFrame] Implement rank (ray-project#1991) [DataFrame] Implemented prod, product, added test suite (ray-project#1994) [DataFrame] Implemented __setitem__, select_dtypes, and astype (ray-project#1941) [DataFrame] Implement diff (ray-project#1996) [DataFrame] Implemented nunique, skew (ray-project#1995) [DataFrame] Implements filter and dropna (ray-project#1959) [DataFrame] Implements df.pipe (ray-project#1999) [DataFrame] Apply() for Lists and Dicts (ray-project#1973) Clean up syntax for supported Python versions. (ray-project#1963) [DataFrame] Implements mode, to_datetime, and get_dummies (ray-project#1956) [DataFrame] Fix dtypes (ray-project#1930) keep_dims -> keepdims (ray-project#1980) ...
* Add flake8 to Travis * Add flake8-comprehensions [flake8 plugin](https://github.com/adamchainz/flake8-comprehensions) that checks for useless constructions. * Use generators instead of lists where appropriate A lot of the builtins can take in generators instead of lists. This commit applies `flake8-comprehensions` to find them. * Fix lint error * Fix some string formatting The rest can be fixed in another PR * Fix compound literals syntax This should probably be merged after #1963. * dict() -> {} * Use dict literal syntax dict(...) -> {...} * Rewrite nested dicts * Fix hanging indent * Add missing import * Add missing quote * fmt * Add missing whitespace * rm duplicate pip install This is already installed in another file. * Fix indent * move `merge_dicts` into utils * Bring up to date with `master` * Add automatic syntax upgrade * rm pyupgrade In case users want to still use it on their own, the upgrade-syn.sh script was left in the `.travis` dir.
What do these changes do?
Replaces syntax with better syntax.
The dict/set/tuple literals (curly braces) for comprehensions and instantiation is
clearer and faster than writing unidiomatic calls to each of those functions.
Related issue number
No.